<?php
class DepartmentsController extends AppController {
	var $name = 'Departments';

	function index() {
		$this->set('departments', $this->Department->find('all'));
	}
	
	function view($id = null) {
		$this->Department->id = $id;
		$this->set('department', $this->Department->read());
	}
	
	function add() {
		if (!empty($this->data)) {
			if ($this->Department->save($this->data)) {
				$this->flash('You have successfully added a Department.', '/departments');
			}
		}
	}
	
	function delete($id) {
		$this->Department->del($id);
		$this->flash('You have successfully removed Department ' . $id . '.', '/departments');
	}
	
	function edit($id) {
		$this->Department->id = $id;
		if (empty($this->data)) {
			$this->data = $this->Department->read();
		}
		else {
			if ($this->Department->save($this->data)) {
				$this->flash('The Department has been updated.', '/departments');
			}
		}
	}
}
?>